package com.firefightingiot.firefightingiot.web.web;

import cn.hutool.json.JSONObject;
import com.firefightingiot.firefightingiot.common.base.BaseController;
import com.firefightingiot.firefightingiot.support.annotaion.Action;
import com.firefightingiot.firefightingiot.support.annotaion.At;
import com.firefightingiot.firefightingiot.support.model.RespEntity;
import com.firefightingiot.firefightingiot.web.service.DeviceSwitchService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.annotation.Resource;

/**
 * @Author: YangYu
 * @ClassName: DeviceSwitchController
 * @Date: Created in 9:23 2023/2/20
 * @Description: 设备开关量控制器
 */
@Action
@RequestMapping(value = "switch")
public class DeviceSwitchController extends BaseController {

    @Resource
    private DeviceSwitchService deviceSwitchService;

    /**
     * @Author YangYu
     * @Description 开关列表
     * @Date Created in 9:37 2022/10/8
     * @Param [jsonParam]
     */
    @At(value = "deviceSwitchList", method = RequestMethod.GET)
    public RespEntity deviceSwitchList(@RequestBody(required = false) JSONObject jsonParam) {
        return deviceSwitchService.deviceSwitchList(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 开关新增、编辑
     * @Date Created in 9:37 2022/10/8
     * @Param [jsonParam]
     */
    @At(value = "deviceSwitchAddOrUpdate", method = RequestMethod.POST)
    public RespEntity deviceSwitchAddOrUpdate(@RequestBody(required = false) JSONObject jsonParam) {
        return deviceSwitchService.deviceSwitchAddOrUpdate(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 开关删除
     * @Date Created in 9:37 2022/10/8
     * @Param [jsonParam]
     */
    @At(value = "deviceSwitchDel", method = RequestMethod.POST)
    public RespEntity deviceSwitchDel(@RequestBody(required = false) JSONObject jsonParam) {
        return deviceSwitchService.deviceSwitchDel(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 开关详情
     * @Date Created in 9:37 2022/10/8
     * @Param [jsonParam]
     */
    @At(value = "deviceSwitchDetail", method = RequestMethod.GET)
    public RespEntity deviceSwitchDetail(@RequestBody(required = false) JSONObject jsonParam) {
        return deviceSwitchService.deviceSwitchDetail(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 开关状态更新
     * @Date Created in 9:37 2022/10/8
     * @Param [jsonParam]
     */
    @At(value = "deviceSwitchStateUpdate", method = RequestMethod.POST)
    public RespEntity deviceSwitchStateUpdate(@RequestBody(required = false) JSONObject jsonParam) {
        return deviceSwitchService.deviceSwitchStateUpdate(jsonParam);
    }

}
